import mill._, scalalib._
import mill.modules.Assembly._

import coursier.maven.MavenRepository

object drum extends ScalaModule {
  override def repositoriesTask = T.task { super.repositoriesTask() ++ Seq(
    MavenRepository("https://mirrors.huaweicloud.com/repository/ivy/")
  ) }

  override def scalacOptions = Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-feature")

  def scalaVersion = "3.1.2"

  // for import javafx
  override def resolutionCustomizer = T.task {
    Some((_: coursier.core.Resolution).withOsInfo(coursier.core.Activation.Os.fromProperties(sys.props.toMap)))
  }

  val akkaVersion = "2.6.19"
  val akkaHttpVersion: String = "10.2.9"
  val akkaDep = List(
    ivy"com.typesafe.akka:akka-actor-typed_2.13:${akkaVersion}",
    ivy"com.typesafe.akka:akka-actor-testkit-typed_2.13:${akkaVersion}",

    ivy"com.typesafe.akka:akka-http_2.13:${akkaHttpVersion}",
    ivy"com.typesafe.akka:akka-http-spray-json_2.13:${akkaHttpVersion}",
    ivy"com.typesafe.akka:akka-http-xml_2.13:${akkaHttpVersion}",

    ivy"de.heikoseeberger:akka-http-circe_2.13:1.39.2",
    ivy"ch.megard:akka-http-cors_2.13:1.1.3",
  )

  val jfxVersion = "17"
  val jfxClassifier = "linux"
  val jfxDep = List(
    ivy"org.scalafx:scalafx_3:17.0.1-R26",
    ivy"org.openjfx:javafx-base:${jfxVersion};classifier=${jfxClassifier}",
    ivy"org.openjfx:javafx-controls:${jfxVersion};classifier=${jfxClassifier}",
    ivy"org.openjfx:javafx-graphics:${jfxVersion};classifier=${jfxClassifier}",
    ivy"org.openjfx:javafx-media:${jfxVersion};classifier=${jfxClassifier}",
    ivy"org.openjfx:javafx-swing:${jfxVersion};classifier=${jfxClassifier}",
  )

  override def ivyDeps = Agg(
    //fxgl
    ivy"com.github.almasb:fxgl:17.1",
    //lwjgl
    //scodec
    ivy"org.scodec::scodec-core:2.1.0",
    //log
    ivy"ch.qos.logback:logback-classic:1.2.3",
    ivy"com.typesafe.scala-logging::scala-logging:3.9.4",
    // test
    ivy"org.scalactic::scalactic:3.2.9",
    ivy"org.scalatest::scalatest:3.2.9"
  ) ++ akkaDep ++ jfxDep
  
  override def mainClass = Some("sren.fxglMain")

  override def assemblyRules = Seq(
    Rule.Append("application.conf"),
    //Rule.ExcludePattern(".*\\.conf"),
    Rule.Append("akka.loggers"),
    Rule.Append("reference.conf"),
    Rule.ExcludePattern("ECLIPSE_.SF"),
    Rule.ExcludePattern("ECLIPSE_.RSA")
  )
}


